<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PCMS内容管理系统</title>
<link href="<?php echo $_tpl['css']; ?>admin.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
	function wconfirm( id )
	{
		if ( id != undefined )
		{
			var ok = window.confirm( '确认要删除?' );
			if ( ok )
			{
				location.href = 'del_html.php?id=' + id;
			}
		}
	}


	function check_all( o )
	{
		var src = o
		var p = "";
		while(p = o.parentNode)
		{
			if( p.tagName.toString().toUpperCase() == "TABLE" )
			{
				break;
			}
			o = p;
		}

		var arr = p.getElementsByTagName("input");
		for( var i = 0; i < arr.length; i++ )
		{
			var tmp = arr[i];
			if( tmp.type.toString().toUpperCase() == "CHECKBOX" && tmp != src )
			{
				tmp.checked = src.checked;
			}
		}
	}

	function is_check_some( o )
	{
		var checked = false;
		var p = '';

		while(p = o.parentNode)
		{
			if( p.tagName.toString().toUpperCase() == "TABLE" )
			{
				break;
			}
			o = p;
		}
		var arr = p.getElementsByTagName("input");
		for( var i = 0; i < arr.length; i++ )
		{
			var tmp = arr[i];
			if( tmp.type.toString().toUpperCase() == "CHECKBOX" )
			{
				if( tmp.checked )
				{
					checked = true;
					break;
				}
			}
		}
		return checked;
	}

	function check_action()
	{
		var op = document.getElementById('op');
		var o = document.getElementById('ck_all');
		if ( op.options[op.selectedIndex].value == 0 )
		{
			alert( '请选择批量操作' );
			return false;
		}
		if ( ! is_check_some( o ) )
		{
			alert( '请选择要操作的对象' );
			return false;
		}

		return true;
	}
</script>
</head>

<body style='width:98%;'>
<table width="99%" border="0" align="center" cellpadding="5" cellspacing="1">
	<form id="searchfrm" method="get">
	<tr>
		<td height="20"><input class="btn2" type="button" onclick="window.location.href='add_html.php?reference=<?php echo $current_url; ?>';" value="添加" /></td>
		<td height="20" align="right" colspan="10"><input type="input" id="title" name="title" size="20" value="输入标题..." /><input type="Submit" name="search" id="search" value="搜索" />
		</td>
	</tr>
	</form>
	</table>
	<table width="99%" border="0" align="center" cellpadding="5" cellspacing="1">
	<form id="form1" method="post" onSubmit="return check_action();">
	<tr>
		<td height="20" align="left" width="15"><input type="checkbox" id="ck_all" name="ck_all" style="width:15px;" onclick="check_all(this);"></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">ID</span></td>
		<td height="20" align="left" bgcolor="#000000" width="39%"><span class="bold">标题</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">栏目</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">审核</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">创建日期</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">编辑</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">操作</span></td>
	</tr>
<?php
	foreach( $data as $index => $value )
	{
		$bgcolor = $index % 2 ? '#323232' : '#272727';
		$cate_name = '';
		if ( isset( $cate_data[$value['cate_id']] ) )
		{
			$cate_name = $cate_data[$value['cate_id']] . ' ';
		}
?>
	<tr>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><input type="checkbox" id="ck_id[]" name="ck_id[]" value="<?php echo $value['id']; ?>" style="width:15px;"></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php echo $value['id']; ?></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><a href="<?php echo empty( $value['save_path'] ) ? 'javascript:void(0);' : substr( config( 'domain.www' ), 0, -1 ) . $value['save_path'] . '?' . time(); ?>" title="<?php echo $cate_name . $value['title_full']; ?>" target="_blank"><font color="<?php echo $value['title_short_color']; ?>"><?php echo $value['title_short']; ?></font></a> <?php if( ! empty( $value['preview_img_path'] ) ){ echo '<a href="' . config( 'domain.tpl.www' ) . substr( $value['preview_img_path'], 1 ) . '" target="_blank" title="附图"><img src="' . $_tpl['images'] . 'pic.gif" border="0" /></a>'; } ?><?php if( $value['home_promote_flag'] == 1 ){ echo '<img src="' . $_tpl['images'] . 'promote.jpg" />'; }?></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php echo $cate_name; ?></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php echo $value['audit_flag'] == 1 ? '已审核' : '未审核'; ?></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php echo date( 'Y-m-d H:i:s', $value['create_time'] ); ?></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php echo $value['username']; ?></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php if( ! empty( $value['save_path'] ) ){ ?><a href="<?php echo substr( config( 'domain.www' ), 0, -1 ) . $value['save_path']; ?>?<?php echo time(); ?>" target="_blank">浏览</a> <?php } ?><a href="set_html.php?id=<?php echo $value['id']; ?>">编辑</a> <a href="javascript:wconfirm(<?php echo $value['id']; ?>);">删除</a></td>
	</tr>
<?php
	}
?>
	<tr>
		<td height="20" bgcolor="#000000" align="left" colspan="16"><input type="checkbox" id="ck_all" name="ck_all" style="width:15px;" onclick="check_all(this);"> <select name="op" id="op"><option value="0">选择批量操作</option><option value="1">删除</option><option value="3">审核</option><option value="4">不审核</option><option value="5">推荐到首页</option><option value="6">取消推荐到首页</option><option value="7">推荐到栏目首页</option><option value="8">取消推荐到栏目首页</option><option value="9">推荐到列表首页</option><option value="10">取消推荐到列表首页</option></select> <input type="submit" name="doaction" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php
	if ( isset( $bar ) )
	{
?>
<a href="<?php echo $bar['first_link']; ?>">首页</a></td><td><a href="<?php echo $bar['prev_link']; ?>">上一页</a></td><td><?php echo $bar['current']; ?> / <?php echo $bar['page']; ?></td><td><a href="<?php echo $bar['next_link']; ?>">下一页</a></td><td><a href="<?php echo $bar['last_link']; ?>">尾页</a><?php
	}
?>
		</td>
	</tr>

	</form>
</table>
</body>
</html>